data "google_billing_account" "account" {
  billing_account = "<%= ctx[:test_env_vars]['billing_acct'] -%>"
}

data "google_project" "project" {
}

resource "google_billing_budget" "<%= ctx[:primary_resource_id] %>" {
  billing_account = data.google_billing_account.account.id
  display_name = "<%= ctx[:vars]['display_name'] %>"
  
  budget_filter {
    projects = ["projects/${data.google_project.project.number}"]
  }

  amount {
    last_period_amount = true
  }

  threshold_rules {
      threshold_percent =  10.0
      # Typically threshold_percent would be set closer to 1.0 (100%).
      # It has been purposely set high (10.0 / 1000%) in this example
      # so it does not trigger alerts during automated testing.
  }
}
